﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
	/// <summary>
	/// 类T_MAILSENDREC。
	/// </summary>
	[Serializable]
	public partial class T_MAILSENDREC
	{
		public T_MAILSENDREC()
		{}
		#region Model
		private string _mailsendid;
		private string _orderid;
		private string _accountid;
		private string _sendor;
		private string _receiver;
		private string _mailsub;
		private string _mailcontent;
		private DateTime? _mailcreatedate;
		private string _mailcreateuserid;
		private string _sendstatus;
		private DateTime? _senttime;
		/// <summary>
		/// 邮件发送编号
		/// </summary>
		public string MAILSENDID
		{
			set{ _mailsendid=value;}
			get{return _mailsendid;}
		}
		/// <summary>
		/// 订单编号
		/// </summary>
		public string ORDERID
		{
			set{ _orderid=value;}
			get{return _orderid;}
		}
		/// <summary>
		/// 用户账号
		/// </summary>
		public string ACCOUNTID
		{
			set{ _accountid=value;}
			get{return _accountid;}
		}
		/// <summary>
		/// 发件人
		/// </summary>
		public string SENDOR
		{
			set{ _sendor=value;}
			get{return _sendor;}
		}
		/// <summary>
		/// 收件人
		/// </summary>
		public string RECEIVER
		{
			set{ _receiver=value;}
			get{return _receiver;}
		}
		/// <summary>
		/// 邮件标题
		/// </summary>
		public string MAILSUB
		{
			set{ _mailsub=value;}
			get{return _mailsub;}
		}
		/// <summary>
		/// 邮件发送内容
		/// </summary>
		public string MAILCONTENT
		{
			set{ _mailcontent=value;}
			get{return _mailcontent;}
		}
		/// <summary>
		/// 邮件生成日期
		/// </summary>
		public DateTime? MAILCREATEDATE
		{
			set{ _mailcreatedate=value;}
			get{return _mailcreatedate;}
		}
		/// <summary>
		/// 邮件生成人
		/// </summary>
		public string MAILCREATEUSERID
		{
			set{ _mailcreateuserid=value;}
			get{return _mailcreateuserid;}
		}
		/// <summary>
		/// 发送状态 C_SendStatus
		/// </summary>
		public string SENDSTATUS
		{
			set{ _sendstatus=value;}
			get{return _sendstatus;}
		}
		/// <summary>
		/// 邮件发送时间
		/// </summary>
		public DateTime? SENTTIME
		{
			set{ _senttime=value;}
			get{return _senttime;}
		}
		#endregion Model


		#region  Method

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public T_MAILSENDREC(string MAILSENDID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select MAILSENDID,ORDERID,ACCOUNTID,SENDOR,RECEIVER,MAILSUB,MAILCONTENT,MAILCREATEDATE,MAILCREATEUSERID,SENDSTATUS,SENTTIME ");
			strSql.Append(" FROM T_MAILSENDREC ");
			strSql.Append(" where MAILSENDID=:MAILSENDID ");
			OracleParameter[] parameters = {
					new OracleParameter(":MAILSENDID", OracleType.VarChar,50)};
			parameters[0].Value = MAILSENDID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["MAILSENDID"]!=null && ds.Tables[0].Rows[0]["MAILSENDID"].ToString()!="")
				{
					this.MAILSENDID=ds.Tables[0].Rows[0]["MAILSENDID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ORDERID"]!=null && ds.Tables[0].Rows[0]["ORDERID"].ToString()!="")
				{
					this.ORDERID=ds.Tables[0].Rows[0]["ORDERID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTID"]!=null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString()!="")
				{
					this.ACCOUNTID=ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SENDOR"]!=null && ds.Tables[0].Rows[0]["SENDOR"].ToString()!="")
				{
					this.SENDOR=ds.Tables[0].Rows[0]["SENDOR"].ToString();
				}
				if(ds.Tables[0].Rows[0]["RECEIVER"]!=null && ds.Tables[0].Rows[0]["RECEIVER"].ToString()!="")
				{
					this.RECEIVER=ds.Tables[0].Rows[0]["RECEIVER"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MAILSUB"]!=null && ds.Tables[0].Rows[0]["MAILSUB"].ToString()!="")
				{
					this.MAILSUB=ds.Tables[0].Rows[0]["MAILSUB"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MAILCONTENT"]!=null && ds.Tables[0].Rows[0]["MAILCONTENT"].ToString()!="")
				{
					this.MAILCONTENT=ds.Tables[0].Rows[0]["MAILCONTENT"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MAILCREATEDATE"]!=null && ds.Tables[0].Rows[0]["MAILCREATEDATE"].ToString()!="")
				{
					this.MAILCREATEDATE=DateTime.Parse(ds.Tables[0].Rows[0]["MAILCREATEDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MAILCREATEUSERID"]!=null && ds.Tables[0].Rows[0]["MAILCREATEUSERID"].ToString()!="")
				{
					this.MAILCREATEUSERID=ds.Tables[0].Rows[0]["MAILCREATEUSERID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SENDSTATUS"]!=null && ds.Tables[0].Rows[0]["SENDSTATUS"].ToString()!="")
				{
					this.SENDSTATUS=ds.Tables[0].Rows[0]["SENDSTATUS"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SENTTIME"]!=null && ds.Tables[0].Rows[0]["SENTTIME"].ToString()!="")
				{
					this.SENTTIME=DateTime.Parse(ds.Tables[0].Rows[0]["SENTTIME"].ToString());
				}
			}
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string MAILSENDID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_MAILSENDREC");
			strSql.Append(" where MAILSENDID=:MAILSENDID ");

			OracleParameter[] parameters = {
					new OracleParameter(":MAILSENDID", OracleType.VarChar,50)};
			parameters[0].Value = MAILSENDID;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_MAILSENDREC (");
			strSql.Append("MAILSENDID,ORDERID,ACCOUNTID,SENDOR,RECEIVER,MAILSUB,MAILCONTENT,MAILCREATEDATE,MAILCREATEUSERID,SENDSTATUS,SENTTIME)");
			strSql.Append(" values (");
			strSql.Append(":MAILSENDID,:ORDERID,:ACCOUNTID,:SENDOR,:RECEIVER,:MAILSUB,:MAILCONTENT,:MAILCREATEDATE,:MAILCREATEUSERID,:SENDSTATUS,:SENTTIME)");
			OracleParameter[] parameters = {
					new OracleParameter(":MAILSENDID", OracleType.VarChar,10),
					new OracleParameter(":ORDERID", OracleType.VarChar,10),
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":SENDOR", OracleType.VarChar,60),
					new OracleParameter(":RECEIVER", OracleType.VarChar,60),
					new OracleParameter(":MAILSUB", OracleType.VarChar,250),
					new OracleParameter(":MAILCONTENT", OracleType.VarChar,2000),
					new OracleParameter(":MAILCREATEDATE", OracleType.DateTime),
					new OracleParameter(":MAILCREATEUSERID", OracleType.VarChar,20),
					new OracleParameter(":SENDSTATUS", OracleType.VarChar,1),
					new OracleParameter(":SENTTIME", OracleType.DateTime)};
			parameters[0].Value = MAILSENDID;
			parameters[1].Value = ORDERID;
			parameters[2].Value = ACCOUNTID;
			parameters[3].Value = SENDOR;
			parameters[4].Value = RECEIVER;
			parameters[5].Value = MAILSUB;
			parameters[6].Value = MAILCONTENT;
			parameters[7].Value = MAILCREATEDATE;
			parameters[8].Value = MAILCREATEUSERID;
			parameters[9].Value = SENDSTATUS;
			parameters[10].Value = SENTTIME;

			DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_MAILSENDREC set ");
			strSql.Append("ORDERID=:ORDERID,");
			strSql.Append("ACCOUNTID=:ACCOUNTID,");
			strSql.Append("SENDOR=:SENDOR,");
			strSql.Append("RECEIVER=:RECEIVER,");
			strSql.Append("MAILSUB=:MAILSUB,");
			strSql.Append("MAILCONTENT=:MAILCONTENT,");
			strSql.Append("MAILCREATEDATE=:MAILCREATEDATE,");
			strSql.Append("MAILCREATEUSERID=:MAILCREATEUSERID,");
			strSql.Append("SENDSTATUS=:SENDSTATUS,");
			strSql.Append("SENTTIME=:SENTTIME");
			strSql.Append(" where MAILSENDID=:MAILSENDID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ORDERID", OracleType.VarChar,10),
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":SENDOR", OracleType.VarChar,60),
					new OracleParameter(":RECEIVER", OracleType.VarChar,60),
					new OracleParameter(":MAILSUB", OracleType.VarChar,250),
					new OracleParameter(":MAILCONTENT", OracleType.VarChar,2000),
					new OracleParameter(":MAILCREATEDATE", OracleType.DateTime),
					new OracleParameter(":MAILCREATEUSERID", OracleType.VarChar,20),
					new OracleParameter(":SENDSTATUS", OracleType.VarChar,1),
					new OracleParameter(":SENTTIME", OracleType.DateTime),
					new OracleParameter(":MAILSENDID", OracleType.VarChar,10)};
			parameters[0].Value = ORDERID;
			parameters[1].Value = ACCOUNTID;
			parameters[2].Value = SENDOR;
			parameters[3].Value = RECEIVER;
			parameters[4].Value = MAILSUB;
			parameters[5].Value = MAILCONTENT;
			parameters[6].Value = MAILCREATEDATE;
			parameters[7].Value = MAILCREATEUSERID;
			parameters[8].Value = SENDSTATUS;
			parameters[9].Value = SENTTIME;
			parameters[10].Value = MAILSENDID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string MAILSENDID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_MAILSENDREC ");
			strSql.Append(" where MAILSENDID=:MAILSENDID ");
			OracleParameter[] parameters = {
					new OracleParameter(":MAILSENDID", OracleType.VarChar,50)};
			parameters[0].Value = MAILSENDID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public void GetModel(string MAILSENDID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select MAILSENDID,ORDERID,ACCOUNTID,SENDOR,RECEIVER,MAILSUB,MAILCONTENT,MAILCREATEDATE,MAILCREATEUSERID,SENDSTATUS,SENTTIME ");
			strSql.Append(" FROM T_MAILSENDREC ");
			strSql.Append(" where MAILSENDID=:MAILSENDID ");
			OracleParameter[] parameters = {
					new OracleParameter(":MAILSENDID", OracleType.VarChar,50)};
			parameters[0].Value = MAILSENDID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["MAILSENDID"]!=null && ds.Tables[0].Rows[0]["MAILSENDID"].ToString()!="")
				{
					this.MAILSENDID=ds.Tables[0].Rows[0]["MAILSENDID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ORDERID"]!=null && ds.Tables[0].Rows[0]["ORDERID"].ToString()!="")
				{
					this.ORDERID=ds.Tables[0].Rows[0]["ORDERID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTID"]!=null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString()!="")
				{
					this.ACCOUNTID=ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SENDOR"]!=null && ds.Tables[0].Rows[0]["SENDOR"].ToString()!="")
				{
					this.SENDOR=ds.Tables[0].Rows[0]["SENDOR"].ToString();
				}
				if(ds.Tables[0].Rows[0]["RECEIVER"]!=null && ds.Tables[0].Rows[0]["RECEIVER"].ToString()!="")
				{
					this.RECEIVER=ds.Tables[0].Rows[0]["RECEIVER"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MAILSUB"]!=null && ds.Tables[0].Rows[0]["MAILSUB"].ToString()!="")
				{
					this.MAILSUB=ds.Tables[0].Rows[0]["MAILSUB"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MAILCONTENT"]!=null && ds.Tables[0].Rows[0]["MAILCONTENT"].ToString()!="")
				{
					this.MAILCONTENT=ds.Tables[0].Rows[0]["MAILCONTENT"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MAILCREATEDATE"]!=null && ds.Tables[0].Rows[0]["MAILCREATEDATE"].ToString()!="")
				{
					this.MAILCREATEDATE=DateTime.Parse(ds.Tables[0].Rows[0]["MAILCREATEDATE"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MAILCREATEUSERID"]!=null && ds.Tables[0].Rows[0]["MAILCREATEUSERID"].ToString()!="")
				{
					this.MAILCREATEUSERID=ds.Tables[0].Rows[0]["MAILCREATEUSERID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SENDSTATUS"]!=null && ds.Tables[0].Rows[0]["SENDSTATUS"].ToString()!="")
				{
					this.SENDSTATUS=ds.Tables[0].Rows[0]["SENDSTATUS"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SENTTIME"]!=null && ds.Tables[0].Rows[0]["SENTTIME"].ToString()!="")
				{
					this.SENTTIME=DateTime.Parse(ds.Tables[0].Rows[0]["SENTTIME"].ToString());
				}
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM T_MAILSENDREC ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		#endregion  Method
	}
}

